+2005-08-31 Øyvind Kolås <pippin@gimp.org>
+
+ * babl/babl-component.h,
+ * babl/babl-core.h,
+ * babl/babl-conversion.h,
+ * babl/babl-extension.h,
+ * babl/babl-format.h,
+ * babl/babl-instance.h,
+ * babl/babl-introspect.h,
+ * babl/babl-image.h,
+ * babl/babl-fish.h,
+ * babl/babl-model.h,
+ * babl/babl-sampling.h,
+ * babl/babl-sanity.h,
+ * babl/babl-type.h: DELETED
+ * babl/babl.h: defines moved from deleted headers. Added
+ documentation.
+ * babl/babl-internal.h: defines moved from deleted headers.
+
+ * babl/Makefile.am: Reflect above changes.
+ * babl/babl-classes.h: redefined conversion functions to return long,
+ and take number of pixels as long.
+ * babl/babl-component.c,
+ * babl/babl-conversion.c,
+ * babl/babl-core.c,
+ * babl/babl-db.h,
+ * babl/babl-extension.c,
+ * babl/babl-fish.c,
+ * babl/babl-format.c,
+ * babl/babl-image.c,
+ * babl/babl-instance.h,
+ * babl/babl-internal.c,
+ * babl/babl-internal.h,
+ * babl/babl-introspect.c,
+ * babl/babl-memory.c,
+ * babl/babl-model.c,
+ * babl/babl-sampling.c,
+ * babl/babl-sanity.c,
+ * babl/babl-type.c,
+ * babl/babl.c,
+ * babl/base/model-cmyk.c,
+ * babl/base/model-gray.c,
+ * babl/base/model-rgb.c,
+ * babl/base/model-ycbcr.c,
+ * babl/base/type-float.c,
+ * babl/base/type-u16.c,
+ * babl/base/type-u8.c,
+ * docs/index-static.html.in,
+ * extensions/CIE-Lab.c,
+ * extensions/naive-CMYK.c,
+ * tests/babl-html-dump.c,
+ * tests/babl_class_name.c,
+ * tests/grayscale_to_rgb.c,
+ * tests/introspect.c,
+ * tests/models.c,
+ * tests/nop.c,
+ * tests/rgb_to_bgr.c,
+ * tests/rgb_to_ycbcr.c,
+ * tests/sanity.c,
+ * tests/srgb_to_lab_u8.c,
+ * tests/types.c: reflect changes in headers.
+
2005-08-31 Øyvind Kolås <pippin@gimp.org>
* Makefile.am,
h_sources = \
babl-classes.h \
- babl-component.h \
- babl-core.h \
- babl-conversion.h \
babl-db.h \
- babl-extension.h \
- babl-format.h \
babl-ids.h \
- babl-instance.h \
babl-internal.h \
- babl-introspect.h \
- babl-image.h \
- babl-fish.h \
babl-memory.h \
- babl-model.h \
- babl-sampling.h \
- babl-sanity.h \
- babl-type.h \
babl-util.h \
babl.h
library_includedir=$(includedir)/babl-$(BABL_API_VERSION)/babl
library_include_HEADERS = \
- babl.h \
- babl-classes.h \
- babl-component.h \
- babl-conversion.h \
- babl-extension.h \
- babl-fish.h \
- babl-ids.h \
- babl-image.h \
- babl-instance.h \
- babl-model.h \
- babl-format.h \
- babl-sampling.h \
- babl-type.h
+ babl.h
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/babl/base
#define _BABL_CLASSES_H
/* Type and Format */
-typedef void (*BablFuncLinear) (void *src,
+typedef long (*BablFuncLinear) (void *src,
void *dst,
int src_pitch,
int dst_pitch,
- int n);
+ long n);
/* TypePlanar, ModelPlanar and FormatPlanar */
-typedef void (*BablFuncPlanar) (int src_bands,
+typedef long (*BablFuncPlanar) (int src_bands,
void *src[],
int src_pitch[],
int dst_bands,
void *dst[],
int dst_pitch[],
- int n);
+ long n);
-typedef void (*BablFuncPlanarBit) (int src_bands,
+typedef long (*BablFuncPlanarBit) (int src_bands,
void *src[],
int src_bit[],
int src_pitch[],
int dst_bit[],
int dst_pitch[],
int dst_bit_pitch[],
- int n);
+ long n);
/* magic number used at the start of all babl objects, used to do
* differentiation in polymorphic functions. (as well as manual
}
Babl *
-babl_component_new (const char *name,
+babl_component_new (void *first_arg,
...)
{
va_list varg;
int luma = 0;
int chroma = 0;
int alpha = 0;
- const char *arg=name;
+ const char *arg=(char*)first_arg;
- va_start (varg, name);
+ va_start (varg, first_arg);
while (1)
{
else
{
- babl_fatal ("unhandled argument '%s' for format '%s'", arg, name);
+ babl_fatal ("unhandled argument '%s' for format '%s'", arg, first_arg);
}
}
va_end (varg);
- babl = component_new (name, id, luma, chroma, alpha);
+ babl = component_new (first_arg, id, luma, chroma, alpha);
{
Babl *ret = db_insert (babl);
}
}
-BABL_CLASS_TEMPLATE (babl_component)
+BABL_CLASS_TEMPLATE (component)
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_COMPONENT_H
-#define _BABL_COMPONENT_H
-
-#include "babl-classes.h"
-#include "babl-instance.h"
-
-
-BABL_DEFINE_CLASS (babl_component)
-#endif
#include "babl-internal.h"
#include "babl-db.h"
-#include "babl-extension.h"
-#include "assert.h"
#include <string.h>
#include <stdarg.h>
}
Babl *
-babl_conversion_new (Babl *source,
- Babl *destination,
- void *first_arg,
+babl_conversion_new (void *first_arg,
...)
{
va_list varg;
int got_func = 0;
const char *arg = first_arg;
+ Babl *source;
+ Babl *destination;
+
+ va_start (varg, first_arg);
+ source = (Babl*) arg;
+ destination = va_arg (varg, Babl*);
+ arg = va_arg (varg, char *);
+
assert (BABL_IS_BABL(source));
assert (BABL_IS_BABL(destination));
- va_start (varg, first_arg);
-
- while (1)
+ while (arg)
{
if (!strcmp (arg, "id"))
}
arg = va_arg (varg, char *);
- if (!arg)
- break;
}
va_end (varg);
}
}
-static void
+static long
babl_conversion_linear_process (BablConversion *conversion,
void *source,
void *destination,
long n)
{
conversion->function.linear (source, destination, src_pitch, dst_pitch, n);
+ return n;
}
-static void
+static long
babl_conversion_planar_process (BablConversion *conversion,
BablImage *source,
BablImage *destination,
dst_data,
destination->pitch,
n);
+ return n;
}
-/* this is the place to insert usage instrumentation into babl */
-void
+long
babl_conversion_process (BablConversion *conversion,
void *source,
void *destination,
long n)
{
- /*TODO: build planar formats if needed when linear pointers are passed in */
- assert (BABL_IS_BABL (conversion));
-
- conversion->processings++;
- conversion->pixels += n;
+ babl_assert (BABL_IS_BABL (conversion));
switch (BABL(conversion)->class_type)
{
}
break;
case BABL_CONVERSION_MODEL_PLANAR:
- assert (BABL_IS_BABL (source));
- assert (BABL_IS_BABL (destination));
+ babl_assert (BABL_IS_BABL (source));
+ babl_assert (BABL_IS_BABL (destination));
babl_conversion_planar_process ( conversion,
(BablImage*) source,
babl_log ("args=(%s, %p, %p, %li) unhandled conversion type: %s",
conversion->instance.name, source, destination, n,
babl_class_name (conversion->instance.class_type));
+ return 0;
break;
}
-
+ return n;
}
-BABL_CLASS_TEMPLATE (babl_conversion)
+BABL_CLASS_TEMPLATE (conversion)
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef BABL_CONVERSION_H
-#define BABL_CONVERSION_H
-
-#include "babl-classes.h"
-#include "babl-instance.h"
-
-void babl_conversion_process (BablConversion *conversion,
- void *source,
- void *destination,
- long n);
-
-Babl * babl_conversion_new (Babl *source,
- Babl *destination,
- void *first_argument,
- ...);
-
-BABL_DEFINE_CLASS_NO_NEW (babl_conversion);
-#endif
#include "babl-ids.h"
#include "util.h"
-static void
+static long
convert_double_double (void *src,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
if (src_pitch == 64 &&
dst_pitch == 64)
{
memcpy (dst, src, n/8);
- return;
+ return n;
}
+
while (n--)
{
(*(double *) dst) = (*(double *) src);
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
-static void
+static long
copy_strip_1 (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
while (n--)
BABL_PLANAR_STEP
}
+ return n;
}
void
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef BABL_CORE_H
-#define BABL_CORE_H
-
-void babl_core_init (void);
-
-#endif
#define _DB_H
#ifndef _BABL_INTERNAL_H
-#error babl-internal.h must be included before babl-db.h, babl-db.h is strictly internal to babl core classes.
+#error babl-db.h is only to be included after babl-internal.h
#endif
-#include "babl-instance.h"
-#include "babl-extension.h"
-
#include <string.h>
#define DB_DEF static inline
collision = db_exist (babl->instance.id, babl->instance.name);
if (collision)
- {
-#if 0
- if (!strcmp (collision->instance.name, babl->instance.name) )
- babl_log ("conflicting name:\n\t\tnew: '%s'\n\t\texisting '%s' from %s",
- babl->instance.name, collision->instance.name,
- collision->instance.creator?BABL(collision->instance.creator)->instance.name:"core");
- else if (collision->instance.id == babl->instance.id)
- babl_log ("conflicting id:\n\t\tnew: '%s' (id=%i)\n\t\texisting '%s' from %s",
- babl->instance.name, babl->instance.id, collision->instance.name,
- collision->instance.creator?BABL(collision->instance.creator)->instance.name:"core");
-#endif
- return collision;
- }
+ return collision;
if (db_entries + 1 > db_size) /* must reallocate storage */
{
}
}
-typedef struct DbExistData
+typedef struct BablDbExistData
{
unsigned int type;
int id;
const char *name;
Babl *ret;
-} DbExistData;
+} BablDbExistData;
DB_DEF int
db_each_exist (Babl *babl,
void *void_data)
{
- DbExistData *data = void_data;
+ BablDbExistData *data = void_data;
- if (data->id &&
- data->id == babl->instance.id)
+ if (data->id && data->id == babl->instance.id)
{
- data->ret = babl;
- return 1;
+ data->ret = babl;
+ return 1; /* stop iterating */
}
- if (data->name &&
- !strcmp (babl->instance.name, data->name))
+ else if (data->name && !strcmp (babl->instance.name, data->name))
{
data->ret = babl;
- return 1;
+ return 1; /* stop iterating */
}
return 0; /* continue iterating */
}
db_exist (int id,
const char *name)
{
- DbExistData data;
+ BablDbExistData data;
data.id = id;
data.name = name;
*/
#define BABL_DYNAMIC_EXTENSIONS
-#define BABL_PATH "/usr/lib/babl:/usr/local/lib/babl:~/.babl";
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define BABL_PATH "~/.babl-0.0:/usr/local/lib/babl-0.0:/usr/lib/babl-0.0";
#define BABL_PATH_SEPERATOR "/"
#define BABL_LIST_SEPERATOR ':'
+#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <assert.h>
#include <dlfcn.h>
#ifndef RTLD_NOW
return 0; /* continue iterating */
}
-BABL_CLASS_TEMPLATE (babl_extension)
+BABL_CLASS_TEMPLATE (extension)
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_EXTENSION_H
-#define _BABL_EXTENSION_H
-
-#include "babl-classes.h"
-#include "babl-instance.h"
-
-Babl * babl_extension_base (void);
-
-Babl * babl_extender (void);
-void babl_set_extender (Babl *new_extender);
-
-Babl * babl_extension_quiet_log (void);
-
-BABL_DEFINE_CLASS (babl_extension)
-#endif
#include "babl-internal.h"
#include "babl-db.h"
-#include "assert.h"
#include <string.h>
#include <stdarg.h>
-#include "babl-type.h"
+/*#include "babl-type.h"
#include "babl-model.h"
#include "babl-image.h"
#include "babl-component.h"
-#include "babl-format.h"
+#include "babl-format.h"*/
static int
each_babl_fish_destroy (Babl *babl,
return buf;
}
-Babl *
-babl_fish_new (Babl *source,
- Babl *destination)
-{
- Babl *babl = NULL;
- const char *name;
-
- assert (BABL_IS_BABL (source));
- assert (BABL_IS_BABL (destination));
-
- name = create_name (source, destination, 0);
-
- babl = babl_malloc (sizeof (BablFishReference) +
- strlen (name) + 1);
- babl->class_type = BABL_FISH;
- babl->instance.id = 0;
- babl->instance.name = ((void *)babl) + sizeof(BablFishReference);
- strcpy (babl->instance.name, name);
- babl->fish.source = (union Babl*)source;
- babl->fish.destination = (union Babl*)destination;
-
- babl->fish.processings = 0;
- babl->fish.pixels = 0;
-
- {
- Babl *ret = db_insert (babl);
- if (ret!=babl)
- babl_free (babl);
- return ret;
- }
-}
-
typedef struct SearchData
{
Babl *source;
BablConversion *result;
} SearchData;
-BablConversion *babl_conversion_find (void *source,
- void *destination)
+Babl *babl_conversion_find (void *source,
+ void *destination)
{
int i=0;
Babl **conversion;
while (conversion[i])
{
if (conversion[i]->conversion.destination == destination)
- return (BablConversion*)conversion[i];
+ return (Babl*)conversion[i];
i++;
}
babl_fatal ("failed, aborting");
Babl *babl = NULL;
char *name = create_name (source, destination, 1);
- assert (BABL_IS_BABL (source));
- assert (BABL_IS_BABL (destination));
+ babl_assert (BABL_IS_BABL (source));
+ babl_assert (BABL_IS_BABL (destination));
- assert (source->class_type == BABL_FORMAT);
- assert (destination->class_type == BABL_FORMAT);
+ babl_assert (source->class_type == BABL_FORMAT);
+ babl_assert (destination->class_type == BABL_FORMAT);
babl = babl_malloc (sizeof (BablFishReference) +
strlen (name) + 1);
Babl *source_format = NULL;
Babl *destination_format = NULL;
- assert (source);
- assert (destination);
+ babl_assert (source);
+ babl_assert (destination);
if (BABL_IS_BABL (source))
{
}
}
- babl_conversion_process (
+ babl_process (
babl_conversion_find (src_img->type[0], dst_img->type[0]),
src_img, dst_img,
n);
}
}
- babl_conversion_process (
+ babl_process (
babl_conversion_find (src_img->type[0], dst_img->type[0]),
src_img, dst_img,
n);
return 0;
}
-static int
+int
babl_fish_reference_process (Babl *babl,
BablImage *source,
BablImage *destination,
n
);
- babl_conversion_process (
+ babl_process (
babl_conversion_find (
BABL(babl->fish.source)->format.model,
babl_model_id (BABL_RGBA)
source_image, rgba_image,
n);
- babl_conversion_process (
+ babl_process (
babl_conversion_find (
babl_model_id (BABL_RGBA),
BABL(babl->fish.destination)->format.model
return 0;
}
-static int
+int
babl_fish_process (Babl *babl,
void *source,
void *destination,
}
-int
-babl_process (Babl *babl,
- void *source,
- void *destination,
- long n)
-{
- assert (babl);
- assert (source);
- assert (destination);
- assert (BABL_IS_BABL (babl));
- assert (n>0);
-
- babl->fish.processings++;
- babl->fish.pixels += n;
-
- if (babl->class_type == BABL_FISH)
- return babl_fish_process (babl, source, destination, n);
-
- if (babl->class_type == BABL_FISH_REFERENCE)
- {
- BablImage *source_image = NULL;
- BablImage *destination_image = NULL;
-
- if (BABL_IS_BABL (source))
- source_image = source;
- if (!source_image)
- source_image = (BablImage*) babl_image_from_linear (
- source, (Babl*)babl->fish.source);
- if (BABL_IS_BABL (destination))
- destination_image = destination;
- if (!destination_image)
- destination_image = (BablImage*) babl_image_from_linear (
- destination, (Babl*)babl->fish.destination);
-
- babl_fish_reference_process (babl, source, destination, n);
-
- babl_free (source_image);
- babl_free (destination_image);
-
- return 0;
- }
-
- babl_log ("eek");
- return -1;
-}
-BABL_DEFINE_INIT (babl_fish)
-BABL_DEFINE_DESTROY (babl_fish)
-BABL_DEFINE_EACH (babl_fish)
+BABL_DEFINE_INIT (fish)
+BABL_DEFINE_DESTROY (fish)
+BABL_DEFINE_EACH (fish)
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef BABL_FISH_H
-#define BABL_FISH_H
-
-#include "babl-classes.h"
-#include "babl-instance.h"
-
-/** create a new BablFish capable of translating between the pixel
- * formats given in source and destination. (use babl_format (string))
- */
-Babl * babl_fish (void *source,
- void *destination);
-
-/* Transform n pixels from source into destination,
- * source and destination can be pointers to linear buffers
- * (or at a later stage of babl development BablImages)
- */
-int babl_process (Babl *babl_fish,
- void *source,
- void *destination,
- int n);
-
-/* whether the BablFish needs a BablImage to do the processing,
- * or a void pointer to a linear buffer is sufficient.
- */
-int babl_fish_needs_image (Babl *babl_fish);
-
-
-
-BABL_DEFINE_CLASS_NO_NEW_NO_ID(babl_fish)
-#endif
#include <stdarg.h>
#include "babl-internal.h"
-#include "babl-sampling.h"
-#include "babl-type.h"
-#include "babl-component.h"
#include "babl-db.h"
static int
}
}
-BABL_CLASS_TEMPLATE (babl_format)
+BABL_CLASS_TEMPLATE (format)
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_FORMAT_H
-#define _BABL_FORMAT_H
-
-#include "babl-classes.h"
-#include "babl-instance.h"
-
-BABL_DEFINE_CLASS (babl_format)
-
-#endif
#include <string.h>
#include <stdarg.h>
-#include <assert.h>
#include "babl-internal.h"
-#include "babl-image.h"
-#include "babl-type.h"
-#include "babl-sampling.h"
-#include "babl-component.h"
-
static Babl *
image_new (BablFormat *format,
int offset=0;
int calc_pitch=0;
- assert (format);
- assert (format->class_type == BABL_FORMAT ||
- format->class_type == BABL_MODEL);
+ babl_assert (format);
+ babl_assert (format->class_type == BABL_FORMAT ||
+ format->class_type == BABL_MODEL);
switch (format->class_type)
{
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_IMAGE_H
-#define _BABL_IMAGE_H
-
-#include "babl-classes.h"
-
-/* babl images are allocated as a single chunk of memory, and
- * thus can be duplicated using duplicate = babl_dup (original);
- *
- * NB: babl_fish_process () frees the images passed in by itself.
- */
-Babl * babl_image (void *first_component,
- ...);
-
-/* create a new BablImage based on a packed BablFormat (or BablModel which
- * is a virtual pixelformat based on the BablModel using only doubles in the
- * order they are listed in the model.
- */
-Babl * babl_image_from_linear (void *buffer,
- Babl *format);
-
-/* create a new babl image similar to the provided babl-image, but where all data
- * is in doubles,..
- */
-Babl * babl_image_double_from_image (Babl *source);
-
-#endif
+++ /dev/null
-#ifndef _BABL_INSTANCE_H
-#define _BABL_INSTANCE_H
-
-#include "babl-classes.h"
-typedef int (*BablEachFunction) (Babl *entry,
- void *data);
-
-
-/* these defines are kept here to keep the typing needed in class
- * headers to a minimum, only the ones overriding the basic api with
- * custom ways of construction.
- */
-#define BABL_DEFINE_CLASS(type_name) \
- \
-void type_name##_init (void); \
-void type_name##_destroy (void); \
-void type_name##_each (BablEachFunction each_fun, \
- void *user_data); \
-Babl * type_name (const char *name); \
-Babl * type_name##_id (int id); \
-Babl * type_name##_new (void *first_arg, \
- ...);
-
-
-#define BABL_DEFINE_CLASS_NO_NEW(type_name) \
- \
-void type_name##_init (void); \
-void type_name##_destroy (void); \
-void type_name##_each (BablEachFunction each_fun, \
- void *user_data); \
-Babl * type_name##_id (int id);
-
-#define BABL_DEFINE_CLASS_NO_NEW_NO_ID(type_name) \
- \
-void type_name##_init (void); \
-void type_name##_destroy (void); \
-void type_name##_each (BablEachFunction each_fun, \
- void *user_data);
-
-#endif
exit (-1);
}
+long babl_conversion_process (Babl *conversion,
+ void *source,
+ void *destination,
+ long n);
+long
+babl_process (Babl *babl,
+ void *source,
+ void *destination,
+ long n)
+{
+ babl_assert (babl);
+ babl_assert (source);
+ babl_assert (destination);
+ babl_assert (BABL_IS_BABL (babl));
+ babl_assert (n>0);
+
+ /* these fields are common between conversions and fishes */
+ babl->fish.processings++;
+ babl->fish.pixels += n;
+
+ /* matches all conversion classes */
+ if (babl->class_type >= BABL_CONVERSION &&
+ babl->class_type <= BABL_CONVERSION_FORMAT_PLANAR)
+ return babl_conversion_process (babl, source, destination, n);
+
+ if (babl->class_type == BABL_FISH)
+ return babl_fish_process (babl, source, destination, n);
+
+ if (babl->class_type == BABL_FISH_REFERENCE)
+ {
+ BablImage *source_image = NULL;
+ BablImage *destination_image = NULL;
+
+ if (BABL_IS_BABL (source))
+ source_image = source;
+ if (!source_image)
+ source_image = (BablImage*) babl_image_from_linear (
+ source, (Babl*)babl->fish.source);
+ if (BABL_IS_BABL (destination))
+ destination_image = destination;
+ if (!destination_image)
+ destination_image = (BablImage*) babl_image_from_linear (
+ destination, (Babl*)babl->fish.destination);
+
+ babl_fish_reference_process (babl, source, destination, n);
+
+ babl_free (source_image);
+ babl_free (destination_image);
+
+ return 0;
+ }
+
+ babl_log ("eek");
+ return -1;
+}
+
void
babl_internal_init (void)
{
{
}
+
+const char *
+babl_name (Babl *babl)
+{
+ babl_assert (BABL_IS_BABL (babl));
+ return babl->instance.name;
+}
#ifndef _BABL_INTERNAL_H
#define _BABL_INTERNAL_H
+#ifdef _BABL_H
+#error babl-internal.h included after babl.h
+#endif
+
#define BABL_MAX_COMPONENTS 32
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include "assert.h"
#include "babl-classes.h"
-#include "babl-instance.h"
+#undef _BABL_INTERNAL_H
+#include "babl.h"
+#define _BABL_INTERNAL_H
+
#include "babl-ids.h"
#include "babl-util.h"
#include "babl-memory.h"
-/* internal classes */
-#include "babl-introspect.h"
-#include "babl-conversion.h"
-#include "babl-extension.h"
-/* */
-void babl_die (void);
+int babl_fish_process (Babl *babl,
+ void *source,
+ void *destination,
+ long n);
+int babl_fish_reference_process (Babl *babl,
+ BablImage *source,
+ BablImage *destination,
+ long n);
+Babl * babl_image_from_linear (void *buffer,
+ Babl *format);
+Babl * babl_image_double_from_image (Babl *source);
+void babl_die (void);
+int babl_sanity (void);
+Babl * babl_extension_base (void);
+
+Babl * babl_extender (void);
+void babl_set_extender (Babl *new_extender);
+
+Babl * babl_extension_quiet_log (void);
+
+void babl_core_init (void);
/**** LOGGER ****/
#include <stdarg.h>
fprintf (stdout, "\n");
}
-#define babl_log(args...) real_babl_log(__FILE__, __LINE__, __FUNCTION__, args)
+#define babl_log(args...) \
+ real_babl_log(__FILE__, __LINE__, __FUNCTION__, args)
-#define babl_fatal(args...) \
- do{ \
- real_babl_log(__FILE__, __LINE__, __FUNCTION__, args);\
- babl_die();} \
- while(0);
+#define babl_fatal(args...) do{ \
+ real_babl_log(__FILE__, __LINE__, __FUNCTION__, args);\
+ babl_die();} \
+while(0)
-/********************/
+#define babl_assert(expr) do{ \
+ if(!(expr)) \
+ { \
+ babl_fatal("Eeeeek"); \
+ assert(expr); \
+ } \
+}while(0)
+/***** LOGGER (end)**/
-#define BABL_CLASS_TYPE_IS_VALID(klass_type) \
+#define BABL_CLASS_TYPE_IS_VALID(klass_type) \
( ((klass_type)>=BABL_INSTANCE ) && ((klass_type)<=BABL_SKY) ?1:0 )
-#define BABL_IS_BABL(obj) \
-(NULL==(obj)?0: \
- BABL_CLASS_TYPE_IS_VALID(((Babl*)(obj))->class_type) \
+#define BABL_IS_BABL(obj) \
+(NULL==(obj)?0 \
+ :BABL_CLASS_TYPE_IS_VALID(((Babl*)(obj))->class_type) \
)
+
extern int babl_hmpf_on_name_lookups;
const char *babl_class_name (BablClassType klass);
#define BABL_DEFINE_EACH(type_name) \
void \
-type_name##_each (BablEachFunction each_fun, \
+babl_##type_name##_each (BablEachFunction each_fun, \
void *user_data) \
{ \
db_each (each_fun, user_data); \
#define BABL_DEFINE_LOOKUP_BY_ID(type_name) \
Babl * \
-type_name##_id (int id) \
+babl_##type_name##_id (int id) \
{ \
Babl *babl; \
babl = db_exist (id, NULL); \
#define BABL_DEFINE_LOOKUP_BY_NAME(type_name) \
Babl * \
-type_name (const char *name) \
+babl_##type_name (const char *name) \
{ \
Babl *babl; \
\
#define BABL_DEFINE_INIT(type_name) \
void \
-type_name##_init (void) \
+babl_##type_name##_init (void) \
{ \
BABL_PRE_INIT_HOOK; \
db_init (); \
#define BABL_DEFINE_DESTROY(type_name) \
void \
-type_name##_destroy (void) \
+babl_##type_name##_destroy (void) \
{ \
BABL_DESTROY_PRE_HOOK; \
- db_each (each_##type_name##_destroy, NULL); \
+ db_each (each_babl_##type_name##_destroy, NULL); \
db_destroy (); \
BABL_DESTROY_HOOK; \
}
* Boston, MA 02111-1307, USA.
*/
-#include "babl.h"
#include "babl-internal.h" /* for babl_log */
#define BABL_LOG
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_INTROSPECT_H
-#define _BABL_INTROSPECT_H
-
-#include "babl-classes.h"
-
-void
-babl_introspect (Babl *babl);
-
-#endif
* Boston, MA 02111-1307, USA.
*/
-#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
{
void *ret;
- assert (size);
+ babl_assert (size);
functions_sanity ();
ret = malloc_f (size + OFFSET);
if (!ret)
- babl_log ("args=(%i): failed", size);
+ babl_fatal ("args=(%i): failed", size);
BAI(ret + OFFSET)->signature = signature;
BAI(ret + OFFSET)->size = size;
{
void *ret;
- assert (IS_BAI (ptr));
+ babl_assert (IS_BAI (ptr));
ret = babl_malloc (BAI(ptr)->size);
memcpy (ret, ptr, BAI(ptr)->size);
return babl_malloc (size);
}
- assert (IS_BAI (ptr));
+ babl_assert (IS_BAI (ptr));
if (size==0)
{
size_t
babl_sizeof (void *ptr)
{
- assert (IS_BAI (ptr));
+ babl_assert (IS_BAI (ptr));
return BAI(ptr)->size;
}
strcpy (ret, src);
return ret;
}
- assert (IS_BAI (dest));
+ babl_assert (IS_BAI (dest));
dst_len = strlen (dest);
ret = dest;
}
}
-BABL_CLASS_TEMPLATE (babl_model)
+BABL_CLASS_TEMPLATE (model)
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_format_H
-#define _BABL_format_H
-
-#include "babl-classes.h"
-#include "babl-instance.h"
-
-BABL_DEFINE_CLASS (babl_model)
-
-#endif
static BablSampling db[(HORIZONTAL_MAX-HORIZONTAL_MIN+1)*
(VERTICAL_MAX-VERTICAL_MIN+1)];
-BablSampling *
+Babl *
babl_sampling (int horizontal,
int vertical)
{
vertical<=4 &&
horizontal>=1 &&
horizontal<=4)
- return &db [ (vertical-1) * 4 + (horizontal-1)];
+ return (Babl*)&db [ (vertical-1) * 4 + (horizontal-1)];
else
babl_log ("babl_samping(%i,%i): arguments out of bounds",
horizontal, vertical);
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_SAMPLING_H
-#define _BABL_SAMPLING_H
-
-#include "babl-classes.h"
-#include "babl-instance.h"
-
-Babl * babl_sampling (int horizontal,
- int vertical);
-
-BABL_DEFINE_CLASS_NO_NEW_NO_ID(babl_sampling)
-#endif
* Boston, MA 02111-1307, USA.
*/
-#include "babl.h"
#include "babl-internal.h"
static int OK;
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_SANITY_H
-#define _BABL_SANITY_H
-
-int babl_sanity (void);
-
-#endif
#include <string.h>
#include <stdarg.h>
-#include <assert.h>
#include "babl-internal.h"
#include "babl-db.h"
{
Babl *babl;
- assert (bits != 0);
- assert (bits % 8 == 0);
+ babl_assert (bits != 0);
+ babl_assert (bits % 8 == 0);
babl = babl_malloc (sizeof (BablType) + strlen (name) + 1);
babl->instance.name = (void*) babl + sizeof (BablType);
}
Babl *
-babl_type_new (const char *name,
+babl_type_new (void *first_arg,
...)
{
va_list varg;
double min_val = 0.0;
double max_val = 0.0;
- const char *arg=name;
+ const char *arg=first_arg;
- va_start (varg, name);
+ va_start (varg, first_arg);
while (1)
{
else
{
- babl_fatal ("unhandled argument '%s' for format '%s'", arg, name);
+ babl_fatal ("unhandled argument '%s' for format '%s'", arg, first_arg);
}
}
va_end (varg);
- babl = type_new (name, id, bits);
+ babl = type_new (first_arg, id, bits);
{
Babl *ret = db_insert (babl);
}
}
-BABL_CLASS_TEMPLATE (babl_type)
+BABL_CLASS_TEMPLATE (type)
+++ /dev/null
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BABL_TYPE_H
-#define _BABL_TYPE_H
-
-#include "babl-classes.h"
-BABL_DEFINE_CLASS (babl_type)
-
-#endif
* Boston, MA 02111-1307, USA.
*/
-#include "babl.h"
#include "babl-internal.h"
-#include "babl-sanity.h"
-#include "babl-introspect.h"
-#include "babl-core.h"
static int ref_count=0;
* Boston, MA 02111-1307, USA.
*/
+/* NOTE! the babl API is polymorphic, it is probably easier to learn
+ * it's usage by studying examples than this header file. The public
+ * functions are attempted explained anyways.
+ */
+
#ifndef _BABL_H
#define _BABL_H
-#if __GNUC__ >=4
- #define BABL_NULL_TERMINATED __attribute_((__sentinel__))
-#else
- #define BABL_NULL_TERMINATED
+#ifdef _BABL_INTERNAL_H
+#error babl.h included after babl-internal.h
+#endif
+#ifndef _BABL_CLASSES_H
+#define Babl void
#endif
+/** Initialize the babl library */
+void babl_init (void);
+
+/** Deinitialize the babl library (frees any resources used, if the number
+ * of calls to babl_destroy() is is equal to the number of calls to
+ * babl_init()
+ */
+void babl_destroy (void);
+
+
+#define BABL_CLASS_NO_NAME(type_name) \
+ \
+void babl_##type_name##_init (void); \
+void babl_##type_name##_destroy (void); \
+Babl * babl_##type_name##_id (int id); \
+void babl_##type_name##_each (BablEachFunction each_fun, \
+ void *user_data);
+
+#define BABL_CLASS(type_name) \
+ \
+BABL_CLASS_NO_NAME (type_name) \
+Babl * babl_##type_name (const char *name); \
+Babl * babl_##type_name##_new (void *first_arg, \
+ ...);
+
+typedef int (*BablEachFunction) (Babl *entry,
+ void *data);
+
+
+/****************************************************************/
+/* BablFish */ BABL_CLASS_NO_NAME (fish)
+/* Create a babl fish capable of converting from source_format to
+ * destination_format, source and destination can be
+ * either strings with the names of the formats or BablFormat objects.
+ */
+Babl * babl_fish (void *source_format,
+ void *destination_format);
+
+/** Process n pixels from source to destination using babl_fish,
+ * returns number of pixels converted.
+ */
+long babl_process (Babl *babl_fish,
+ void *source,
+ void *destination,
+ long n);
+
+/****************************************************************/
+/* BablImage */ BABL_CLASS_NO_NAME (image)
+/*
+ * Babl images can be used for planar buffers instead of linear buffers for
+ * babl_process(), BablImages are still experimental, for now BablImages can be
+ * passed to babl_process, two different babl_process() functions will be
+ * needed for this since the polymorphism cannot be trusted to work on linear
+ * buffers.
+ *
+ * Babl * babl_image (BablComponent *component1,
+ * void *data,
+ * int pitch,
+ * int stride,
+ * [BablComponent *component1,
+ * void *data,
+ * int pitch,
+ * int stride,
+ * ...]
+ * NULL);
+ */
+Babl * babl_image (void *first_component,
+ ...);
+
+
+
+/****************************************************************/
+/* BablType */ BABL_CLASS (type)
+/*
+ * A data type that babl can have in it's buffers, requires
+ * conversions to and from "double" to be registered before
+ * passing sanity.
+ *
+ * Babl * babl_type_new ( const char *name,
+ * "bits", int bits,
+ * ["min_val", double min_val,]
+ * ["max_val", double max_val,]
+ * NULL);
+ */
+
+
+/****************************************************************/
+/* BablComponent */ BABL_CLASS (component)
+/*
+ * Babl * babl_component_new (const char *name,
+ * NULL);
+ */
+
+
+/****************************************************************/
+/* BablModel */ BABL_CLASS (model)
+/*
+ * Babl * babl_model_new (["name", const char *name,]
+ * BablComponent *component1,
+ * [BablComponent *componentN, ...]
+ * NULL);
+ *
+ * If no name is provided a name is generated by concatenating the
+ * name of all the involved components.
+ *
+ */
+
+/****************************************************************/
+/* BablSampling */ BABL_CLASS_NO_NAME (sampling)
+/**/
+Babl * babl_sampling (int horizontal,
+ int vertical);
+
+/****************************************************************/
+/* BablFormat */ BABL_CLASS (format)
+/*
+ * Babl * babl_format_new (["name", const char *name,]
+ * BablModel *model,
+ * [BablType *type,]
+ * [BablSampling, *sampling,]
+ * BablComponent *component1,
+ * [[BablType *type,]
+ * [BablSampling *sampling,]
+ * BablComponent *componentN,
+ * ...]
+ * ["planar",]
+ * NULL);
+ *
+ * Provided BablType and|or BablSampling is valid for the following
+ * components as well. If no name is provided a (long) descriptive
+ * name is used.
+ */
+
+
+/****************************************************************/
+/* BablExtension */ BABL_CLASS (extension)
+/*
+ * BablExtension objects are only used internally in babl.
+ */
+
+/****************************************************************/
+/* BablConversion */ BABL_CLASS (conversion)
+/*
+ * Babl * babl_conversion_new (<BablFormat *source, BablFormat *destination|
+ * BablModel *source, BablModel *destination|
+ * BablType *source, BablType *destination>,
+ * <"linear"|"planar">, BablConversionFunc conv_func,
+ * NULL);
+ */
+
+
+const char *babl_name (Babl *babl); /* returns the name of a babl object */
+void babl_introspect (Babl *babl); /* introspect a given BablObject */
+
+#undef BABL_CLASS
#include <stdlib.h>
-#include "babl-classes.h"
-#include "babl-component.h"
-#include "babl-conversion.h"
-#include "babl-fish.h"
-#include "babl-image.h"
-#include "babl-model.h"
-#include "babl-format.h"
-#include "babl-type.h"
-#include "babl-sampling.h"
-
-void babl_init (void);
-void babl_destroy (void);
#endif
);
}
-static void
+static long
rgb_to_cmyk (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
cmyk_to_rgb (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
#if 0
-static void
+static long
rgb_to_and_from_cmy (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
}
-static void
+static long
rgb_to_gray (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
while (n--)
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
rgb_to_gray_2_2 (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
while (n--)
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
gray_2_2_to_rgb (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
while (n--)
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
gray_to_rgb (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
while (n--)
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
gray_alpha_premultiplied_to_rgba (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
assert (src_bands == 2);
*(double*)dst[3] = alpha;
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
rgba_to_gray_alpha_premultiplied (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY;
assert (src_bands == 4);
*(double*)dst[1] = alpha;
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
non_premultiplied_to_premultiplied (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
premultiplied_to_non_premultiplied (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
static void
NULL);
}
-static void
+static long
copy_strip_1 (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
while (n--)
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
g3_gamma_2_2 (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
g3_inv_gamma_2_2 (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
}
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
non_premultiplied_to_premultiplied (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
premultiplied_to_non_premultiplied (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
static void
NULL);
}
-static void
+static long
rgb_to_ycbcr (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
ycbcr_to_rgb (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
static void
#include "babl.h"
#include "babl-ids.h"
-static void
+static long
convert_double_float (void *src,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
-static void
+static long
convert_float_double (void *src,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
void
#include "babl-ids.h"
-static inline void
+static inline long
convert_double_u16_scaled (double min_val,
double max_val,
unsigned short min,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
-static inline void
+static inline long
convert_u16_double_scaled (double min_val,
double max_val,
unsigned short min,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
-static void \
+static long \
convert_##name##_double (void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
- int n) \
+ long n) \
{ \
- convert_u16_double_scaled (min_val, max_val, min, max, \
+ return convert_u16_double_scaled (min_val, max_val, min, max, \
src, dst, src_pitch, dst_pitch, n);\
} \
-static void \
+static long \
convert_double_##name (void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
- int n) \
+ long n) \
{ \
- convert_double_u16_scaled (min_val, max_val, min, max, \
+ return convert_double_u16_scaled (min_val, max_val, min, max, \
src, dst, src_pitch, dst_pitch, n);\
}
#include "babl.h"
#include "babl-ids.h"
-static inline void
+static inline long
convert_double_u8_scaled (double min_val,
double max_val,
unsigned char min,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
src += src_pitch;
dst += dst_pitch;
}
+ return n;
}
-static inline void
+static inline long
convert_u8_double_scaled (double min_val,
double max_val,
unsigned char min,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
-static void \
+static long \
convert_##name##_double (void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
- int n) \
+ long n) \
{ \
- convert_u8_double_scaled (min_val, max_val, min, max, \
+ return convert_u8_double_scaled (min_val, max_val, min, max, \
src, dst, src_pitch, dst_pitch, n); \
} \
-static void \
+static long \
convert_double_##name (void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
- int n) \
+ long n) \
{ \
- convert_double_u8_scaled (min_val, max_val, min, max, \
+ return convert_double_u8_scaled (min_val, max_val, min, max, \
src, dst, src_pitch, dst_pitch, n); \
}
<a name='NEWS'></a>
<h2>News</h2>
<!--NEWS-->
+ <p>Also see the <a href='http://cvs.gnome.org/viewcvs/babl/ChangeLog'>CVS ChangeLog</a>.</p>
<a name='Features'></a>
<h2>Features</h2>
<li class='stable'>Planar and linear buffers</li>
<li class='stable'>Thread safety for processing.</li>
- <li class='unstable'>Extension and introspection of formats,
+ <li class='unstable'>Extension and <a href='http://pippin.gimp.org/babl/introspect.txt'>introspection</a> of formats,
color models, components and datatypes</li>
<li class='unstable'>Horizontal an vertical subsampling (for
implementing 4:2:2 4:2:0 4:1:1 etc. chroma subsampling)</li>
-static void
+static long
rgb_to_lab (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
lab_to_rgb (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
static void
}
-static inline void
+static inline long
convert_double_u8_scaled (double min_val,
double max_val,
unsigned char min,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
src += src_pitch;
dst += dst_pitch;
}
+ return n;
}
-static inline void
+static inline long
convert_u8_double_scaled (double min_val,
double max_val,
unsigned char min,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
-static void \
+static long \
convert_##name##_double (void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
- int n) \
+ long n) \
{ \
- convert_u8_double_scaled (min_val, max_val, min, max, \
+ return convert_u8_double_scaled (min_val, max_val, min, max, \
src, dst, src_pitch, dst_pitch, n); \
} \
-static void \
+static long \
convert_double_##name (void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
- int n) \
+ long n) \
{ \
- convert_double_u8_scaled (min_val, max_val, min, max, \
+ return convert_double_u8_scaled (min_val, max_val, min, max, \
src, dst, src_pitch, dst_pitch, n); \
}
);
}
-static inline void
+static inline long
convert_double_u16_scaled (double min_val,
double max_val,
unsigned short min,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
-static inline void
+static inline long
convert_u16_double_scaled (double min_val,
double max_val,
unsigned short min,
void *dst,
int src_pitch,
int dst_pitch,
- int n)
+ long n)
{
while (n--)
{
dst += dst_pitch;
src += src_pitch;
}
+ return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
-static void \
+static long \
convert_##name##_double (void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
- int n) \
+ long n) \
{ \
- convert_u16_double_scaled (min_val, max_val, min, max, \
+ return convert_u16_double_scaled (min_val, max_val, min, max, \
src, dst, src_pitch, dst_pitch, n);\
} \
-static void \
+static long \
convert_double_##name (void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
- int n) \
+ long n) \
{ \
- convert_double_u16_scaled (min_val, max_val, min, max, \
+ return convert_double_u16_scaled (min_val, max_val, min, max, \
src, dst, src_pitch, dst_pitch, n);\
}
#include "babl.h"
#include "util.h"
-static void rgb_to_cmyk (int src_bands,
+static long rgb_to_cmyk (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n);
-static void cmyk_to_rgb (int src_bands,
+ long n);
+static long cmyk_to_rgb (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n);
+ long n);
int
init (void)
{
return 0;
}
-static void
+static long
rgb_to_cmyk (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
-static void
+static long
cmyk_to_rgb (int src_bands,
void **src,
int *src_pitch,
int dst_bands,
void **dst,
int *dst_pitch,
- int n)
+ long n)
{
BABL_PLANAR_SANITY
BABL_PLANAR_STEP
}
+ return n;
}
* Boston, MA 02111-1307, USA.
*/
-#include "babl.h"
-#include "babl-internal.h" /* for babl_log */
+#include "babl-internal.h" /* needed for babl_log */
static void model_html (Babl *babl);
static void type_html (Babl *babl);
#include <string.h>
#include <stdio.h>
-#include "babl.h"
#include "babl-internal.h"
struct
* Boston, MA 02111-1307, USA.
*/
-#include "babl.h"
#include "babl-internal.h"
#define PIXELS 5
* Boston, MA 02111-1307, USA.
*/
-#include "babl.h"
#include "babl-internal.h"
int
* RGBA data */
#include <stdlib.h>
-#include "babl.h"
-#include "math.h"
+#include <math.h>
#include "babl-internal.h"
int OK=1;
*/
#include "babl.h"
-#include "babl-internal.h"
int
main (int argc,
#include <math.h>
-#include "babl.h"
#include "babl-internal.h"
#define PIXELS 3
#include <math.h>
-#include "babl.h"
#include "babl-internal.h"
#define PIXELS 6
* Boston, MA 02111-1307, USA.
*/
-#include "babl.h"
-#include "babl-sanity.h"
#include "babl-internal.h"
int
*/
#include <math.h>
-#include "babl.h"
#include "babl-internal.h"
#define PIXELS 6
-#include "babl.h"
-#include "math.h"
+#include <math.h>
#include "babl-internal.h"
int OK=1;